package com.tcg.prototype;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CardsAltActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.cards_alt);
		
		Card[] cards = generateCards();
		LinearLayout container = (LinearLayout) findViewById(R.id.card_container);
//		for (Card card : cards) {
//			getLayoutInflater().inflate(R.layout.small_card, container);
//		}
		
		for(int i = 0; i < cards.length; i++)
		{
			getLayoutInflater().inflate(R.layout.small_card, container);
			populateCardView(container.getChildAt(i), cards[i]);
		}
		//populateCardView(cardView, card);
	}
	
	private void populateCardView(View cardView, Card card) {
		// TODO Auto-generated method stub
		TextView title = (TextView) cardView.findViewById(R.id.card_title);
		TextView gold_cost = (TextView) cardView.findViewById(R.id.card_gold_cost);
		TextView mana_cost = (TextView) cardView.findViewById(R.id.card_mana_cost);
		ImageView image = (ImageView) cardView.findViewById(R.id.card_image);
		
		title.setText(card.title);
		gold_cost.setText("Gold: " + card.goldCost);
		mana_cost.setText("Mana: " + card.manaCost);
		Resources res = getResources();
		image.setImageDrawable(res.getDrawable(card.image));

	}

	private Card[] generateCards() {
		Card[] result = new Card[5];
		for (int i = 0; i < 5; i++)
			result[i] = Card.getRandomCard();
		
		return result;
	}

}
